package com.hb.unic.core.context.support;

import com.hb.unic.core.context.Application;
import com.hb.unic.core.context.UnicApplicationContext;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;

import lombok.extern.slf4j.Slf4j;

/**
 * 应用准备启动时
 *
 * @since v1.0，2023/8/30 20:47，create by Mr.Huang.
 */
@Slf4j
public class UnicApplicationPreparedListener implements ApplicationListener<ApplicationPreparedEvent> {

    @Override
    public void onApplicationEvent(ApplicationPreparedEvent event) {
        for (String propertiesFilename : UnicEnvironmentPostProcessor.LOAD_PROPERTIES_FILENAMES) {
            log.info("Loading properties: {}", propertiesFilename);
        }
        // 设置应用上下文
        Application.setContext(new UnicApplicationContext(event.getApplicationContext()));
    }
}
